#pragma once

#include "Business/Policy/ClassicBusinessContext.h"
#include "afxwin.h"
// CEditBalanceDlg dialog


class CClassicBusinessSettingDlg : public CDialog
{
	DECLARE_DYNAMIC(CClassicBusinessSettingDlg)

public:
	enum OPERATE_TYPE {ADD,POSITION_ADD,MODIFY,UPDATE_BALANCE};

	CClassicBusinessSettingDlg(ClassicBusinessArgument const& argument, 
		ContractCodes const& contracts, 
		OPERATE_TYPE operateType);   // standard constructor
	virtual ~CClassicBusinessSettingDlg();

// Dialog Data
	enum { IDD = IDD_CLASSIC_BUSINESS_SETTING_DLG };


	ClassicBusinessArgument const& GetArgument() const {return m_argument;}
	int GetCount() const {return m_count;}
	int GetPosition() const {return m_position;}

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()

private:
	CEdit m_maxQuantityEdit;
	CComboBox m_majorCombo;
	CComboBox m_minorCombo;
	CComboBox m_typeCombo;
	CEdit m_minOpenBlanceEdit;
	CEdit m_minProfitBlanceEdit;
	CEdit m_bullishOpenBalanceEdit;
	CEdit m_bullishOffsetBalanceEdit;
	CEdit m_bullishStoplostBalanceEdit;
	CEdit m_bearishOpenBalanceEdit;
	CEdit m_bearishOffsetBalanceEdit;
	CEdit m_bearishStoplostBalanceEdit;
	CStatic m_countLabel;
	CEdit m_countEdit;
	CStatic m_positionLabel;
	CEdit m_positionEdit;

	ClassicBusinessArgument m_argument;
	ContractCodes const& m_contracts;
	OPERATE_TYPE m_operateType;
	int m_count;
	int m_position;
	int m_type;
protected:
	afx_msg void OnBnClickedBtnOk();
	afx_msg void OnBnClickedBtnCancel();
	afx_msg void OnCbnSelchangeMajorCombo();
	afx_msg void OnCbnSelchangeTypeCombo();


	virtual BOOL OnInitDialog();

private:
	void UpdateArgument();
	void InitComboData();
	void InitControlText(int majorContract, int minorContract);
	void InitComboSel(CComboBox& combo,int contract);
	void DisableControl(char const* balanceStr = NULL);
	bool Validate() const;
	void InitMinorCombo(UINT majorContract);
};
